package guowenlong.golf.ui.personal.changepsaaword;

import android.text.TextUtils;
import guowenlong.golf.C;
import guowenlong.golf.entity.ChangePasswordEntity;
import rx.Observer;

/**
 * des   : 描述 author: Gavin email : guowenlong20000@gmail.com time  : 2016年08月31日 下午 5:19.
 */
public class ChangePasswordPresenter extends ChangePasswordContract.Presenter {

  @Override
  public void onStart() {
  }

  @Override
  public void changePassword(String token, String password, String rePassword) {
    mRxManager.add(mModel.changePassword(token, password,rePassword).subscribe(new Observer<ChangePasswordEntity>() {
      @Override
      public void onCompleted() {

      }

      @Override
      public void onError(Throwable e) {

      }

      @Override
      public void onNext(ChangePasswordEntity changePasswordEntity) {
        if (changePasswordEntity.getStatus() == C.RESULT_OK) {
          mView.changePasswordSuccess(changePasswordEntity);
        } else if (changePasswordEntity.getStatus() == C.RESULT_ERROR) {
          if (TextUtils.isEmpty(changePasswordEntity.getError_message()) )return;
          mView.changePasswordError(changePasswordEntity);
        }
      }
    }));
  }
}